<template>
  <div class="listItem" @click="offFn">
    <dir class="image">
      <img v-for="(img, index) in imageList" v-lazy="img" :key="index" />
    </dir>
    <div class="info">
      <div class="title">{{ item.title }}</div>
      <div class="map">{{ item.desc }}</div>
      <div class="tag">
        <span v-for="(i, index) in item.tags" :key="index">{{ i }}</span>
      </div>
      <div class="moniy">
        <span>{{ item.price }}</span
        >元
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    item: {
      type: Object,
      required: true
    },
    off: {
      type: Boolean
    }
  },
  data () {
    return {
      imageList: []
    }
  },
  created () {
    this.imageList.push(`http://liufusong.top:8080${this.item.houseImg}`)
  },
  methods: {
    offFn () {
      if (!this.off) {
        this.$router.push(`/detail/${this.item.houseCode}`)
      }
    }
  }
}
</script>

<style lang="less" scoped>
.listItem {
  height: 120px;
  display: flex;
  padding-top: 18px;
  border-bottom: 1px solid #e5e5e5;
  .image {
    margin: 0;
    padding: 0;
    width: 106px;
    height: 80px;
    img {
      width: 106px;
      height: 80px;
    }
  }
  .info {
    padding: 0 0 0 12px;
    line-height: 1.3em;
    .title {
      width: 255px;
      font-size: 15px;
      font-weight: 700;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .map {
      font-size: 12px;
      color: #afb2b3;
    }
    .tag {
      overflow: hidden;
      height: 21px;
      span {
        font-size: 12px;
        padding: 4px;
        margin-right: 4px;
        border-radius: 5px;
        background-color: #e1f5f8;
        color: #39becd;
      }
      span:nth-child(2n) {
        background-color: #e1f5ed;
        color: #3fc28c;
      }
      span:nth-child(3n) {
        background-color: #e6f2ff;
        color: #5aabfd;
      }
    }
    .moniy {
      margin-top: 5px;
      font-size: 12px;
      color: red;
      span {
        font-size: 16px;
        font-weight: 700;
      }
    }
  }
}
</style>
